# -*- coding:utf8 -*-

def fib(n):
    if n == 1 or n == 2:
        return 1
    else:
        return fib(n - 1) + fib( n - 2)


def fib2(n):

    def loop(n, result_of_n_1, result_of_n_2):
        if n == 3:
            return result_of_n_1 + result_of_n_2
        else:
            return loop(n - 1, result_of_n_1 + result_of_n_2, result_of_n_1)

    if n == 1 or n == 2:
        return 1
    else:
        return loop(n, 1, 1)


if __name__ == "__main__":
    result = fib(19)
    print("result=%d" % result)

    result = fib2(10)
    print("result=%d" % result)